package com.example.androidfftaudio;

import android.graphics.Bitmap;
import android.graphics.Canvas;
 
public class Sprite {
       private int y = 0; 
       public int x;
       private int ySpeed;
       private CSurfaceView gameView;
       private Bitmap bmp;
      
       public Sprite(CSurfaceView gameView, Bitmap bmp,int speed) {
             this.gameView=gameView;
             this.bmp=bmp;
             ySpeed = speed;
       }
 
       private void update(int speed) {
        //     if (getY() > gameView.getHeight() - bmp.getHeight() - ySpeed) {
         //           ySpeed = -2;
         //    }
             if (getY() + ySpeed< 0) {
                    ySpeed = speed;
             }
             setY(getY() + ySpeed);
             
       }
       public boolean isCollision(){
       //    System.out.println(String.valueOf(y));
    	   return getY()>=950;
       }
      
       public void onDraw(Canvas canvas,int x, int ySpeed) {
             update(ySpeed);
      //       System.out.println("speed:"+ySpeed);
             canvas.drawBitmap(bmp, x , getY(), null); // 10
       }
     
       public void onDraw1(Canvas canvas,int ySpeed){
    	   update(ySpeed);
    	   canvas.drawBitmap(bmp, 100, getY(),null);
       }

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}
	
	public void setYspeed(int ySpeed){
		this.ySpeed = ySpeed;
	}
}  